package com.yc.happ.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import com.yc.happ.entity.Volunteer;
import com.yc.happ.service.VolunteerService;
import com.yc.happ.util.DBHelper;
public class VolunteerServiceImpl implements VolunteerService {

	public static Integer count=10017;
	@Override
	public boolean register(Volunteer vol) {
		boolean flag = true;
		vol.setVid(count++);
		vol.setIsChoose(0);
		vol.setVscore(0);
		try {
			flag = DBHelper.save(vol) > 0;
		} catch (Exception e) {
			count--;
			flag = false;
		}
		return flag;
	}
	@Override
	public boolean update(String name, String phone, String special, String date, String time1, String time2, String uname) {
		
		String sql="update volunteer set vname=?,vphone=?,vspecial=?,vdate=?,vtimeStart=?,vtimeEnd=? where vuname=?";
		List<Object> params=new ArrayList<Object>();
		params.add(0, name);
		params.add(1, phone);
		params.add(2, special);
		params.add(3, date);
		params.add(4, time1);
		params.add(5, time2);
		params.add(6, uname);
		double d=DBHelper.doUpdate(sql, params);
		if(d>0){
			return true;
		}else{
			return false;
		}
		
	}

}
